package 剑指Offer1;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;

public class _45数组中数字出现的次数 {
    public int[] singleNumbers(int[] nums) {
        if(nums == null || nums.length == 0) return new int[0];
        HashMap<Integer,Integer> map = new HashMap<>();
        int[] res = new int[2];
        int i = 0;
        for (int num : nums) {
            map.put(num,map.getOrDefault(num,0)+1);
        }
        for (Map.Entry<Integer, Integer> num : map.entrySet()) {
            if(num.getValue() == 1){
                res[i++] = num.getKey();
            }
        }
        return res;

    }

    public static void main(String[] args) {
        int[] num = {4,1,4,6};
        HashSet<Integer> hashSet = new HashSet<>();
        for (int i : num) {
            hashSet.add(i);

        }
        System.out.println(hashSet);
    }
}
